﻿using System;
using System.Web;
using ASPNETVN.PORTAL.Components.Security;

namespace ASPNETVN.PORTAL.Masters.ACTP
{
    public partial class HeaderControl : System.Web.UI.UserControl
    {
        protected string LogoffLink = string.Empty;

        protected override void OnInit(EventArgs e)
        {
            // If user logged in, customize welcome message
            if (Request.IsAuthenticated)
            {
                //WelcomeMessage.Text = "<a href='" + Global.GetApplicationPath(Request) + "/Default.aspx?page=ChangePassword' class='SiteLink'>" + Global.RM.GetString("SYSTEM_WELCOME") + " " + PortalSecurity.CurrentUser.Identity.Email + "</a> <span>|</span>";
                //WelcomeMessage.ToolTip = PortalSecurity.CurrentUser.Identity.ToString();

                // if authentication mode is Cookie, provide a logoff link
                if (Context.User.Identity.AuthenticationType == "Forms")
                {
                    LogoffLink = "<a href='" + Global.GetApplicationPath(Request) + "/Admin/Logoff.aspx' class=SiteLink> " + Global.RM.GetString("SYSTEM_LOGOUT") + "</a>";
                }

            }
            else
            {
                // Obtain Portal from Current Context
                Components.Configuration.Items.Portal portal = (Components.Configuration.Items.Portal)HttpContext.Current.Items["Portal"];

                // Allow register?
                if (portal.AllowRegister)
                {
                    LogoffLink = "<a href='" + Global.GetApplicationPath(Request) + "/Register.aspx' class=SiteLink> " + Global.RM.GetString("SYSTEM_REGISTER") + "</a> <span>|</span> " + "<a href='" + Global.GetApplicationPath() + "/SignIn.aspx' class=SiteLink> " + Global.RM.GetString("SYSTEM_SIGNIN") + "</a>";
                }
                else
                {
                    LogoffLink = "<a href='" + Global.GetApplicationPath(Request) + "/SignIn.aspx' class=SiteLink> " + Global.RM.GetString("SYSTEM_SIGNIN") + "</a>";
                }
            }
            base.OnInit(e);
        }
        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}